/** 
 *  @file
 *  @brief   圆管（TUBE）梁截面属性使用解析公式计算类
 *  @author  yuanchenxi
 *  @date    2024.04.12
 *  @version v1.0
 *  @par Copyright(c):  ShenGong  Simulation corporation
 */

#include "TubeSectionFormulaCalculator.h"
#include "DataStructure/Common/Real.h"
#include "DataStructure/Common/Constant.h"

using SG::DataStructure::Common::Real;
using SG::DataStructure::Common::PI;
using SG::DataStructure::FEM::PBARLData;
using SG::DataStructure::FEM::PBARData;
using SG::FEMSolver::Element::TubeSectionFormulaCalculator;

void TubeSectionFormulaCalculator::Compute
(
const SG::DataStructure::FEM::PBARLData& section,
_OUT SG::DataStructure::FEM::PBARData&   property,
_OUT SG::Algebra::Point&                 centroid
) const
{
    Real ri{section.m_dimension[1]};
    Real ro{section.m_dimension[0]};

    property.m_id  = section.m_id;
    property.m_mId = section.m_mId;
    property.m_A   = PI * (ro * ro - ri * ri);
    /* Real yS = 0.0;
    Real zS = 0.0;
    Real yC = 0.0;
    Real zC = 0.0; */
    property.m_I1  = 0.25 * PI * (ro * ro * ro * ro - ri * ri * ri * ri);
    property.m_I2  = property.m_I1;
    property.m_I12 = 0.0;
    property.m_J   = 2.0 * property.m_I1;
    property.m_K1  = 0.5;
    property.m_K2  = 0.5;
    // Real m{ri / ro};
    // property.m_K1 = 6.0 * (1.0 + m * m) * (1.0 + m * m) / (7.0 * (1.0 + m * m) * (1.0 + m * m) + 20.0 * m * m);
    // property.m_K2 = property.m_K1;
    property.m_NSM = section.m_nsm;
    property.m_FE  = 0.0;
    property.SetStressPoints ({ ro,   0.0,
                                0.0,  ro,
                               -ro,   0.0,
                                0.0, -ro});
    centroid.m_x = 0.0;
    centroid.m_y = 0.0;
    centroid.m_z = 0.0;
}